{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

<Hds::AppFrame @hasSidebar={{@showSidebar}} @hasHeader={{@showSidebar}} @hasFooter={{false}} as |Frame|>
  <Frame.Header>
    <Hds::AppHeader @hasA11yRefocus={{false}} data-test-app-header>
      <:logo>
        <Hds::AppHeader::HomeLink
          @icon="vault"
          @route="vault"
          @text="HashiCorp Vault Home Menu"
          @ariaLabel="Navigate to HashiCorp Vault Home"
        />
      </:logo>
      <:utilityActions>
        <Hds::Button @isIconOnly={{true}} @icon="home" @text="Docs index" @route="docs" />
      </:utilityActions>
    </Hds::AppHeader>
  </Frame.Header>

  <Frame.Sidebar data-test-sidebar-nav>
    <DocfyOutput @scope="docs" as |docs|>
      {{#let docs.children as |directories|}}
        {{#let docs.pages as |pages|}}
          <Hds::AppSideNav>
            <Hds::AppSideNav::List as |Nav|>
              <Nav.BackLink @text="Back to work (Vault UI)" @route="vault" />
              <Nav.Link @icon="home" @route="docs.index" @text="Home" />
              <Nav.Link @icon="edit" @route="docs.how-to-docfy" @text="How to docfy" />
              <Nav.Title>
                Components
              </Nav.Title>
              <Nav.Item>
                {{! FILTER + COMPONENT LIST }}
                <ZDocfyFilter @components={{get (find-by "name" "components" directories) "pages"}} />
              </Nav.Item>

              <Nav.Title>
                Contributing docs
              </Nav.Title>
              {{! Top level files in docs/ directory }}
              {{#each pages as |page|}}
                {{#let (concat "docs." (if page.relativeUrl page.relativeUrl "index")) as |url|}}
                  <Nav.Link @route={{url}} @text={{page.title}} />
                {{/let}}
              {{/each}}

              {{! Sub directories within docs/ (aside from 'components') }}
              {{#each directories as |subDirectory|}}
                {{#if (not-eq subDirectory.name "components")}}
                  <Nav.Title>
                    {{capitalize subDirectory.label}}
                  </Nav.Title>

                  {{#each subDirectory.pages as |page|}}
                    {{#let (concat "docs." (if page.relativeUrl page.relativeUrl "index")) as |url|}}
                      <Nav.Link @route={{url}}>
                        {{page.title}}
                      </Nav.Link>
                    {{/let}}
                  {{/each}}
                {{/if}}
              {{/each}}
            </Hds::AppSideNav::List>
          </Hds::AppSideNav>
        {{/let}}
      {{/let}}
    </DocfyOutput>
  </Frame.Sidebar>

  <Frame.Main id="docfy-content">
    {{outlet}}
  </Frame.Main>
</Hds::AppFrame>